#ifndef ROOTDIR
#ROOTDIR = /usr/local
#export ROOTDIR
#endif

#TOOLPREFIX=/home/helena/ap96/build/gcc-3.4.4-2.16.1/build_mips/bin/mips-linux-uclibc-
CC=$(TOOLPREFIX)gcc
LD=$(TOOLPREFIX)ld
AS=$(TOOLPREFIX)as
AR=$(TOOLPREFIX)ar
STRIP=$(TOOLPREFIX)strip
RANLIB=$(TOOLPREFIX)ranlib
NM=$(TOOLPREFIX)nm
OBJCOPY=$(TOOLPREFIX)objcopy

LIB_PATH = $(INSTALL_ROOT)/lib
INCLUDES= -I$(INSTALL_ROOT)/include/upnp
#LIB_PATH = /home/helena/ap96/rootfs-ap96-small.build/lib
#INCLUDES= -I/home/helena/ap96/rootfs-ap96-small.build/include/upnp
LIBS= -L$(LIB_PATH) -lpthread -lupnp -lixml -lthreadutil
FILES= main.o gatedevice.o pmlist.o util.o config.o

CFLAGS += -Wall -g -O2

ifdef HAVE_LIBIPTC
ifdef LIBIPTC_PREFIX
LIBS += -L$(LIBIPTC_PREFIX)/lib
INCLUDES += -I$(LIBIPTC_PREFIX)/include
endif

LIBS += -liptc
INCLUDES += -DHAVE_LIBIPTC
FILES += iptc.o
endif

all: upnpd

upnpd: $(FILES)
	$(CC) $(CFLAGS) $(FILES) $(LIBS) -o $@
	$(STRIP) -s $@
	@echo "make $@ finished on `date`"

%.o:	%.c
	$(CC) $(CFLAGS) $(INCLUDES) -c $<

romfs:
	$(ROMFSINST) /bin/upnpd
	$(ROMFSINST) /bin/upnp_xml.sh
	$(ROMFSINST) etc/upnpd.conf /etc_ro/linuxigd/upnpd.conf
	$(ROMFSINST) etc/ligd.gif /etc_ro/linuxigd/ligd.gif

clean:
	rm -f *.o upnpd
